import KZJRequest from '../index'
import { TRequestDefaultResult } from '../type'

enum Users {
  Detail = '/user/detail',
  PlayList = '/user/playlist',
  event = '/user/event',
  share = '/share/resource',
  count = '/user/subcount',
  del = '/event/del'
}

export function getCount(uid: number) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Users.count,
    params: { uid },
    showLoading: true,
    takeCookie: true
  })
}

export function getUserDetail(uid: number) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Users.Detail,
    params: { uid },
    showLoading: true,
    immediately: true,
    takeCookie: true
  })
}

export function delEvent(evId: number) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Users.del,
    params: { evId },
    showLoading: true,
    immediately: true,
    takeCookie: true
  })
}

export function getUserPlayList(uid: number, limit = 5) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Users.PlayList,
    params: { uid, limit },
    showLoading: true
  })
}

export function getEvent(uid: number, limit = 10) {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Users.event,
    params: { uid, limit },
    showLoading: true,
    takeCookie: true,
    immediately: true
  })
}

export function shareEvent(id: number, msg: string, type = 'song') {
  return KZJRequest.get<TRequestDefaultResult>({
    url: Users.share,
    params: { id, msg, type },
    showLoading: true,
    takeCookie: true,
    immediately: true
  })
}
